import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score
from sklearn.feature_selection import SelectKBest, chi2, mutual_info_classif
# import xgboost as xgb
from xgboost import XGBRegressor
import joblib
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import GridSearchCV
import  os



df=pd.read_csv('../../data/raw/test2.csv')
# print(df.info())

    #TODO 第二步：热编码
    #进行热编码 LabelEncoder：有序分类变量（这样可以转换成1列，而onehot和这个labelencoder一样作用，只不过LabelEncoder会返回一列）
    #将所有的object类型提取出来
ordered_cols = df.select_dtypes(include='object').columns
le = LabelEncoder()
    #循环对提取出来的object依次热编码
for col in ordered_cols:
    if col in df.columns:
        df[col] = le.fit_transform(df[col])

# feature_names=['MonthlyIncome','EmployeeNumber','TotalWorkingYears','YearsAtCompany','YearsInCurrentRole','YearsWithCurrManager','Age','DistanceFromHome','OverTime','YearsSinceLastPromotion','StockOptionLevel','JobLevel','MaritalStatus','JobRole','JobSatisfaction']
feature_names=['OverTime','StockOptionLevel','JobLevel','JobRole','MaritalStatus','TotalWorkingYears','Age','JobInvolvement','YearsWithCurrManager','YearsInCurrentRole','JobSatisfaction','YearsAtCompany','EnvironmentSatisfaction','NumCompaniesWorked','WorkLifeBalance','MonthlyIncome']
x=df[feature_names]
y=df['Attrition']
# es=joblib.load('../models/model1')
es=joblib.load('model2')
y_pre = es.predict_proba(x)[:,1]
#y_pre = es.predict(x)
# y_pre = es.predict_proba(x)

print(f'预测的AUC为{roc_auc_score(y,y_pre)}')
